package syc;

public class StoreR implements Runnable {
    int count = 0;
    @Override
    public void run() {
        while (true){
            //不能自己指定，非静态方法用this，静态用字节码对象
                if (extracted()) break;

        }
    }

    private synchronized boolean extracted() {
        if (count == 50){
            return true;
        }else {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            count++;
            System.out.println(Thread.currentThread().getName()+"正在卖票"+count);
        }
        return false;
    }
}
